<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="dy20941">REASSIGN OWNED</title>
  <body>
    <p id="sql_command_desc">Changes the ownership of database objects owned by a database role.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="sql_command_synopsis">REASSIGN OWNED BY <varname>old_role</varname> [, ...] TO <varname>new_role</varname></codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p><codeph>REASSIGN OWNED</codeph> changes the ownership of database objects owned by any of

        the <varname>old_role</varname>s to <varname>new_role</varname>. </p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt><varname>old_role</varname></pt>
          <pd>The name of a role. The ownership of all the objects in the current database, and of
            all shared objects (databases, tablespaces), owned by this role will be reassigned to
              <varname>new_role</varname>. </pd>
        </plentry>
        <plentry>
          <pt><varname>new_role</varname></pt>
          <pd>The name of the role that will be made the new owner of the affected objects.</pd>
        </plentry>
      </parml>
    </section>
    <section id="section5">
      <title>Notes</title>
      <p><codeph>REASSIGN OWNED</codeph> is often used to prepare for the removal of one or more
        roles. Because <codeph>REASSIGN OWNED</codeph> does not affect objects in other databases,
        it is usually necessary to run this command in each database that contains objects owned
        by a role that is to be removed. </p>
      <p><codeph>REASSIGN OWNED</codeph> requires privileges on both the
        source role(s) and the target role.</p>
      <p>The <xref href="DROP_OWNED.xml#topic1"><codeph>DROP OWNED</codeph></xref> command is an
        alternative that simply drops all of the database objects owned by one or more roles.
          <codeph>DROP OWNED</codeph> requires privileges only on the source role(s).</p>
      <p>The <codeph>REASSIGN OWNED</codeph> command does not affect any privileges granted to the
        <varname>old_role</varname>s on objects that are not owned by them. Likewise, it does
        not affect default privileges created with <codeph>ALTER DEFAULT PRIVILEGES</codeph>.
        Use <codeph>DROP OWNED</codeph> to revoke such privileges.</p>
    </section>
    <section id="section6">
      <title>Examples</title>
      <p>Reassign any database objects owned by the role named <codeph>sally</codeph> and
          <codeph>bob</codeph> to <codeph>admin</codeph>;</p>
      <codeblock>REASSIGN OWNED BY sally, bob TO admin;</codeblock>
    </section>
    <section id="section7">
      <title>Compatibility</title>
      <p>The <codeph>REASSIGN OWNED</codeph> command is a Greenplum Database extension. </p>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p><codeph><xref href="DROP_OWNED.xml#topic1" type="topic" format="dita"/></codeph>,
            <codeph><xref href="DROP_ROLE.xml#topic1" type="topic" format="dita"/></codeph>,
            <codeph><xref href="ALTER_DATABASE.xml#topic1">ALTER DATABASE</xref></codeph></p>
    </section>
  </body>
</topic>
